﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace App
{
    public partial class consumedetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            if (Request.QueryString["id"] != null)
            {
                int id = 0;
                int.TryParse(Request.QueryString["id"], out id);
                if (id <= 0) return;

                string querySql = "SELECT c.Id,a.AccountName,c.InsertDateTime,(c.Cost/100.00) AS Cost,ImagePath"
                                    + " FROM Consume AS c INNER JOIN Account AS a ON c.AccountId = a.Id"
                                    + " WHERE c.AccountId = " + id;
                DataSet ds = DbHelperSQLite.Query(querySql);
                if (ds != null && ds.Tables != null && ds.Tables[0].Rows != null)
                {
                    this.gvList.DataSource = DbHelperSQLite.Query(querySql).Tables[0];
                    this.gvList.DataBind();
                }
                else
                {
                    //无数据
                }
            }

        }

        protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.gvList.PageIndex = e.NewPageIndex;
            LoadData();
        }
    }
}